<?php
// +----------------------------------------------------------------------
// | CatchAdmin [Just Like ～ ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
// +----------------------------------------------------------------------
// | Author: JaguarJack [ njphper@gmail.com ]
// +----------------------------------------------------------------------
namespace catchAdmin\externalGoods\excel;

use catchAdmin\customs\model\Order as orderModel;
use catchAdmin\customs\model\HnOrderDetail as orderDetailModel;
use catchAdmin\externalGoods\model\TenantGoods;
use catcher\library\excel\ExcelContract;
use PhpOffice\PhpSpreadsheet\Style\Alignment;

class tenantGoodsExport implements ExcelContract
{
    protected $tenantGoodsModel;

    public function __construct(TenantGoods $tenantGoodsModel)
    {
        $this->tenantGoodsModel = $tenantGoodsModel;
    }
    /**
     * 设置头部
     *
     * @time 2020年09月08日
     * @return string[]
     */
    public function headers(): array
    {
        // TODO: Implement headers() method.
        return [
            '商品SPU',
            '商品名称',
        ];
    }
//    public function getPushInventoryAttr($value)
//    {
//        $status = [0=>'未推送',1=>'电子口岸已暂存',2=>'电子口岸申报中',3=>'发送海关成功',4=>'发送海关失败',100=>'海关退单',120=>'海关入库', 300=>'人工审核',399=>'海关审结',800=>'放行',899=>'结关',500=>'查验',501=>'扣留移送通关',502=>'扣留移送缉私',503=>'扣留移送法规',599=>'其它扣留',700=>'退运'];
//
//        return array_key_exists($value,$status)?$status[$value]:$value;
//    }

    /**
     * 处理数据
     *
     **/
    public function sheets()
    {
        $list = $this->tenantGoodsModel->getExportList();
//        foreach ($list as $key => &$value){
//            //$value->split_status = $value->split_status ? '已拆分':'未拆分';
//            if($value->status == 0){
//                $value->status = '未出库';
//            }else if($value->status == 1){
//                $value->status = '全部出库';
//            }else if($value->status == 2){
//                $value->status = '部分出库';
//            }
//        }
        return $list;
    }

    /**
     * 设置开始行
     *
     * @time 2020年09月08日
     * @return int
     */
    public function setRow()
    {
        return 1;
    }
    /**
     * 设置行宽
     *
     * @time 2020年09月08日
     * @return int
     */
    public function setWidth()
    {
        return [
            "A"=>30,
            "B"=>20,
            "C"=>20,
            "D"=>30,
            "E"=>30,
            "F"=>20,
            "G"=>20,
            "H"=>20,
            "I"=>20,
            "J"=>30,
            "K"=>30,
            "L"=>20,
            "M"=>20,
            "N"=>20,
            "O"=>20,
            "P"=>20,
            "Q"=>20,
            "R"=>20,
            "S"=>20,
            "T"=>30,
            "U"=>30,
        ];
    }

    /**
     * 设置标题
     *
     * @time 2020年09月08日
     * @return array
     */
//    public function setTitle()
//    {
//        return [
//            'A1:J1', '订单导出', Alignment::HORIZONTAL_CENTER
//        ];
//    }
}